package com.tian.view.anim.view_anim

import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.tian.view.R
import com.tian.view.databinding.ViewFourBottonBinding

/**
 * @author tiansongtao, Email:tiansongtao@up366.com
 * @date 2022/12/14 10:04
 *
 * 透明度动画
 */
class DrawableAnimFragment : Fragment() {

    private lateinit var b: ViewFourBottonBinding


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        b = ViewFourBottonBinding.inflate(inflater)
        return b.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        (requireActivity() as AppCompatActivity).supportActionBar?.title = "逐帧动画"
        b.mbtOne.text = "xml定义逐帧动画"
        b.ibShow.visibility = View.VISIBLE
        b.ibShow.setImageResource(R.drawable.drawable_anim)
        //b.ibShow.setBackgroundResource(R.drawable.drawable_anim)

        b.mbtOne.setOnClickListener {
            (b.ibShow.drawable as AnimationDrawable).start()
        }

        b.mbtTwo.visibility = View.GONE
        b.mbtThree.visibility = View.GONE
        b.mbtFour.visibility = View.GONE
    }


}